#!/usr/bin/env ruby
require 'colorize'

CHAPTERS = {1 => (1..46),
            2 => (1..97),
            3 => (1..82),
            4 => (1..79),
            5 => (1..52)}


def show_for_chapter(chapter, mode=:all)
  files = `git ls-files | egrep 'ex-.*scm'`.split

  for exercise in CHAPTERS[chapter]
    exercise = "0" + exercise.to_s if exercise < 10
    ex_file = "ex-#{chapter}.#{exercise}.scm"
    color = (files.member? ex_file) ? :green : :red
    if (color == :green) && (`grep -i "TODO:" #{ex_file}` != "")
      color = :yellow
    end

    puts ex_file.send(color) unless (mode == :incomplete && color == :green)
  end
end

mode = (ARGV.first == '-i') ? :incomplete : :all
show_for_chapter(2, mode)
